import 'package:flutter/material.dart';
import 'package:flutter_app/components/layout.dart';
import 'package:flutter_app/utils/AppUtil.dart';
import 'package:flutter/services.dart';
class InvitePage extends StatefulWidget {
  @override
  _InvitePageState createState() => _InvitePageState();
}

Widget WhiteText(String text) {
  return Text(
    text,
    style: TextStyle(color: Colors.white, height: 1.7),
  );
}

Widget WhiteContainer({Widget child}) {
  return Container(
    margin: EdgeInsets.symmetric(horizontal: 15.0),
    padding: EdgeInsets.fromLTRB(20, 50, 20, 20),
    decoration: BoxDecoration(
        color: Colors.white,
        border: Border.all(color: Color(0xFFD6DCFE), width: 5)),
    child: child,
  );
}

Widget ProgressItem(String text) {
  return Container(
      width: 180,
      padding: EdgeInsets.symmetric(vertical: 13.0, horizontal: 15.0),
      decoration: BoxDecoration(
          color: Colors.blueAccent.withOpacity(0.06),
          borderRadius: BorderRadius.only(
              bottomRight: Radius.circular(20), topRight: Radius.circular(20))),
      child: Text(
        text,
        style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
      ));
}

class _InvitePageState extends State<InvitePage> {
  @override
  Widget build(BuildContext context) {
    return AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle.light,
      child: RepaintBoundary(
          key: Key("repaintWidgetKey"),
          child: Scaffold(
            body: Stack(
              children: [
                Column(
                  children: [
                    Expanded(
                      child: Container(
                        color: Color(0xFF0B64FF),
                        child: SingleChildScrollView(
                          child: Column(
                            children: [
                              Stack(
                                children: [
                                  Image.asset(
                                      "assets/images/invite/tuijianTop.png",
                                      fit: BoxFit.cover),
                                  Container(
                                    margin: EdgeInsets.fromLTRB(0, 200, 0, 0),
                                    alignment: Alignment.center,
                                    child: Text(
                                      "邀请好友购买产品赚取投资返佣",
                                      textAlign: TextAlign.center,
                                      style: TextStyle(
                                          color: Colors.white,
                                          fontSize: 30,
                                          fontFamily: 'bold'),
                                    ),
                                  ),
                                ],
                              ),
                              SizedBox(
                                height: 20,
                              ),
                              WhiteContainer(
                                  child: Column(
                                children: [
                                  Row(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: [
                                      Text(
                                        '9HQPG4',
                                        style: TextStyle(
                                            fontWeight: FontWeight.bold,
                                            color: Colors.blueAccent,
                                            fontSize: 25),
                                      ),
                                      IconButton(
                                          color: Colors.blueAccent,
                                          iconSize: 19,
                                          icon: Icon(Icons.copy),
                                          onPressed: () {
                                            AppUtil.copy('9HQPG4');
                                          })
                                    ],
                                  ),
                                  RowBetween(
                                    children: [
                                      FlatButton(
                                          onPressed: () {},
                                          minWidth: 130,
                                          textColor: Colors.white,
                                          shape: StadiumBorder(),
                                          color: Colors.blueAccent,
                                          child: Text('注册邀链接')),
                                      FlatButton(
                                          onPressed: () {},
                                          minWidth: 130,
                                          textColor: Colors.white,
                                          shape: StadiumBorder(),
                                          color: Colors.orange,
                                          child: Text('分享邀请海报')),
                                    ],
                                  ),
                                  Text(
                                    '好友入金购买产品，笔笔投资跟您返佣0.04%',
                                    style: TextStyle(fontSize: 12),
                                  )
                                ],
                              )),
                              SizedBox(
                                height: 20,
                              ),
                              WhiteContainer(
                                  child: Row(
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: [
                                  Wrap(
                                    spacing: 10,
                                    direction: Axis.vertical,
                                    children: [
                                      ProgressItem('邀请链接分享给好友'),
                                      ProgressItem('好友注册并入金投资'),
                                      ProgressItem('您完成KYC2身份认证'),
                                      ProgressItem('收到好友投资对应佣金'),
                                    ],
                                  ),
                                ],
                              )),
                              SizedBox(
                                height: 20,
                              ),
                              WhiteContainer(
                                child: RowBetween(
                                  children: [
                                    FlatButton(
                                        onPressed: () {Navigator.pushNamed(context, '/invite/record');},
                                        minWidth: 130,
                                        textColor: Colors.white,
                                        shape: StadiumBorder(),
                                        color: Colors.blueAccent,
                                        child: Text('邀请记录')),
                                    FlatButton(
                                        onPressed: () {Navigator.pushNamed(context, '/invite/invitee');},
                                        minWidth: 130,
                                        textColor: Colors.white,
                                        shape: StadiumBorder(),
                                        color: Colors.orange,
                                        child: Text('我的邀请人')),
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: 10,
                              ),
                              // 活动规则
                              Container(
                                margin: EdgeInsets.symmetric(
                                    vertical: 20.0, horizontal: 10.0),
                                padding: EdgeInsets.symmetric(
                                    vertical: 15.0, horizontal: 15.0),
                                decoration: BoxDecoration(
                                    border: Border.all(
                                        color: Colors.black54.withOpacity(0.04),
                                        width: 7)),
                                child: ColumnStart(
                                  children: [
                                    WhiteText('活动规则'),
                                    WhiteText(
                                        '1.好友接受邀请注册后，被邀请人每购买一笔双币或优买产品，会产生相应比例的返佣。'),
                                    WhiteText(
                                        '2.购买产品返佣比例：0.04%。假设您邀请的好友购买了一笔10BTC面值的产品，那么您可获得0.04%*10BTC相应面值的USDT。'),
                                    WhiteText('3.佣金将以USDT形式发放到邀请人。'),
                                    WhiteText('4.被邀请人在注册后90天内的投资，可计入邀请人佣金。'),
                                    WhiteText('5.邀请人需要完成Lv.2级别身份认证后，佣金才能到账。'),
                                    WhiteText('6.返佣时间：每天20:00(UTC+8)。'),
                                    WhiteText(
                                        '7.如邀请人或被邀请人违反了平台风控规则，Matrixport有权将返佣记录定义为无效。'),
                                    WhiteText('8.活动解释权归Matrixport所有。')
                                  ],
                                ),
                              )
                            ],
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
                Positioned(
                  top: 30.0,
                  left: 15.0,
                  child: InkWell(
                    child: Container(
                      width: 35.0,
                      height: 35.0,
                      decoration: BoxDecoration(
                          color: Colors.black.withOpacity(0.2),
                          borderRadius: BorderRadius.all(Radius.circular(25))),
                      child: Icon(Icons.arrow_back_ios_outlined,size: 16,color: Colors.white,),
                    ),
                    onTap: () {
                      Navigator.pop(context);
                    },
                  ),
                ),
              ],
            ),
          )),
    );
  }
}
